#ifndef RENDERMANAGER_H
#define RENDERMANAGER_H

#include <vector>
#include <memory>
#include <string>
#include <mutex>

#include <QWidget>
#include <QtWidgets/QGraphicsView>

#include "renderinterface.h"

//==================================================================================================
// 
//==================================================================================================
class RenderManager
{
public:
    static RenderManager& Instance();

    void Init(QWidget* parent, IRenderHandler* handler);

    void* AddRender(const std::string& render_id);

    void RemoveRender(const std::string& render_id);

    void* FindRender(const std::string& render_id);

    void UpdateLabelText(const std::string& render_id, const std::string& text);

    void UpdateRenderDisplay();

private:
    struct RenderEntry
    {
        IRenderView* view = nullptr;
        std::string id;
    };
    typedef std::shared_ptr<RenderEntry> RenderEntrySP;

private:
    void Update1x2Display();
    void UpdateNxNDisplay(uint32_t n);

private:
    std::vector<RenderEntrySP> m_renders;
    QWidget* m_parent_wnd = nullptr;
    std::mutex m_mutex;
    IRenderHandler* m_handler = nullptr;
};

#endif // RENDERMANAGER_H
